package br.com.srv.config;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Carregar configurações do String.
 * @author aurindo
 *
 */
public class ConfiguracaoSpring {
	
	/**
	 * Fábrica de beans.
	 */
	private static BeanFactory beanFactory;
	
	public ConfiguracaoSpring() {
		System.out.println("Carregando configurações...");
		beanFactory = new ClassPathXmlApplicationContext("br/com/srv/config/applicatioConfig.xml");
		System.out.println("Carregou configurações");
	}
	
	/**
	 * Carregar bean.
	 * @param beanName Nome do bean
	 * @return Bean (Object)
	 */
	public static Object getBean(String beanName) {
		return getBeanFactory().getBean(beanName);
	}
	
	/**
	 * Pegar a fábrica de beans.
	 * @return fábrica de bean.
	 */
	private static BeanFactory getBeanFactory() {
		return beanFactory;
	}

}
